if(!jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.envDef.envDtls.medBus.serDtls.SerDtls")) {
    jsx3.lang.Class.defineClass("tibco.admin.enterpriseAssets.envDef.envDtls.medBus.serDtls.SerDtls",
            jsx3.gui.Block,
            null,
            function (plugin) {

                plugin.prototype.subscribeAll = function() {
                    var me = this;
                    tibco.admin.PubSub.subscribe(tibco.admin.enterpriseAssets.envDef.EventID.EMS_ROW_SELECTED, me, me.populateEMSDetails)
                    tibco.admin.PubSub.subscribe(tibco.admin.enterpriseAssets.envDef.EventID.EMS_CREATE, me, me.createEMSDetails)
                    tibco.admin.PubSub.subscribe(tibco.admin.enterpriseAssets.envDef.EventID.EMS_CLEAR, me, me.resetEMSPane)
                    tibco.admin.PubSub.subscribe(tibco.admin.enterpriseAssets.envDef.EventID.ENVIRONMENT_ROW_SELECTED, me, me.listenForEnvironmentDeselect)
                    this.addMode = false;
                    this.passedItems = {};
                }

                plugin.prototype.unsubscribeAll = function() {
                    var me = this;
                    tibco.admin.PubSub.unsubscribe(tibco.admin.enterpriseAssets.envDef.EventID.EMS_ROW_SELECTED, me)
                    tibco.admin.PubSub.unsubscribe(tibco.admin.enterpriseAssets.envDef.EventID.EMS_CREATE, me)
                    tibco.admin.PubSub.unsubscribe(tibco.admin.enterpriseAssets.envDef.EventID.EMS_CLEAR, me)
                    tibco.admin.PubSub.unsubscribe(tibco.admin.enterpriseAssets.envDef.EventID.ENVIRONMENT_ROW_SELECTED, me)
                }

                plugin.prototype.setConnTypeDisplay = function(value) {
                    var blockJNDI = this.getDescendantOfName("blkJNDI27E");
                    var blockDirect = blockJNDI.getParent().getChild("blkDirect27E");
                    var parent = blockDirect.getParent();
                    if(value == tibco.admin.Main.getServer().getDynamicProperty("@@option_sltConTypeDIRECT27E")) {
                        blockJNDI.setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                        blockDirect.setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                        parent.adoptChild(blockJNDI,true);
                        this.passedItems["txtTopicConnFactory27E"] = true;
                        this.passedItems["sharedJNDIResource"] = true;
                        this.passedItems["txtProURL27E"] = blockDirect.getDescendantOfName("txtProURL27E").getValue() != "";
                        this.enableSaveBtn();
                    }
                    else {
                        blockJNDI.setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                        blockDirect.setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                        parent.adoptChild(blockDirect, true);
                        this.passedItems["txtProURL27E"] = true;
                        this.passedItems["txtTopicConnFactory27E"] = blockJNDI.getDescendantOfName("txtTopicConnFactory27E").getValue() != "";
                        this.passedItems["sharedJNDIResource"] = blockJNDI.getDescendantOfName("btnSelectJNDI27E").getText() != tibco.admin.Main.getServer().getDynamicProperty("@@select27E");
                        this.enableSaveBtn();
                    }
                }

                plugin.prototype.listenForEnvironmentDeselect = function(objEvent) {
                    if(this.handler && this.handler.isDetailsInEditMode()) {
                        return;
                    }
                    if(!objEvent.environmentName) {
                        this.clearEMSDetails(objEvent);
                    }
                    else {
                        this.environmentID = objEvent.environmentID;
                    }
                }

                plugin.prototype.editEMSDetails = function(button) {
                    this.handler.beginDetailsEditMode();
                    if(!this.addMode) {
                        this.passedItems = {"txtName_27E":true,
                            "txtReconnAttemptCount_27E": true,
                            "txtDelay_27E":true,
                            "txtEMSUsername27E":true}
                    }
                    var textboxes = this.getDescendantsOfType(jsx3.gui.TextBox, false);
                    button.getParent().getChild("btnEdit_27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    button.getParent().getChild("btnSave_27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    button.getParent().getChild("btnCancel_27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    button.getParent().getChild("btnTestConnection_27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    for(var i = 0; i < textboxes.length; i++) {
                        textboxes[i].setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true).getParent().getChild(1).
                                setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    }
                    this.getDescendantOfName("sltConType27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true).getParent().getChild(1).
                            setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    this.getDescendantOfName("btnSelectJNDI27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true)
                            .getParent().getChild(1).setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    if(this.getDescendantOfName("blkJNDI27E").getDisplay() == jsx3.gui.Block.DISPLAYBLOCK) {
                        this.passedItems["txtTopicConnFactory27E"] = true;
                    }
                    else {
                        this.passedItems["txtProURL27E"] = true;
                    }
                }

                plugin.prototype.cancelEditEMS = function(button) {
                    this.handler.endDetailsEditMode();
                    var textboxes = this.getDescendantsOfType(jsx3.gui.TextBox, false);
                    button.getParent().getChild("btnEdit_27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    button.getParent().getChild("btnSave_27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    button.getParent().getChild("btnTestConnection_27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    button.setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    for(var i = 0; i < textboxes.length; i++) {
                        textboxes[i].setDisplay(jsx3.gui.Block.DISPLAYNONE, true).getParent().getChild(1).
                                setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    }
                    this.getDescendantOfName("sltConType27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true).getParent().getChild(1).
                            setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    var selectLabel = this.getDescendantOfName("lblContype_27E");
                    this.setConnTypeDisplay(selectLabel.getText());
                    this.getDescendantOfName("btnSelectJNDI27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true)
                            .getParent().getChild(1).setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);

                    var msg = new Object();
                    msg.subject = tibco.admin.enterpriseAssets.envDef.EventID.EMS_REFRESH;
                    tibco.admin.PubSub.publish(msg);
                }

                plugin.prototype.populateEMSDetails = function(objEvent) {
                    if(this.handler && this.handler.isDetailsInEditMode()) {
                        return;
                    }
                    if(objEvent.entityID) {
                        this.setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                        this.entityID = objEvent.entityID;
                        this.getDescendantOfName("btnEdit_27E").setEnabled(jsx3.gui.Form.STATEENABLED, true);
                        this.getDescendantOfName("lblName_27E").setText(objEvent.name, true).
                                getParent().getChild("txtName_27E").setValue(objEvent.name);
                        this.getDescendantOfName("lblMilliseconds27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                        this.getDescendantOfName("lblDescription_27E").setText(objEvent.description, true).
                                getParent().getChild("txtDescription_27E").setValue(objEvent.description);
						var connctionTypeValue = tibco.admin.Main.getServer().getDynamicProperty("@@option_sltConType" + objEvent.connectionType + "27E");
                        this.getDescendantOfName("lblContype_27E").setText(connctionTypeValue, true)
                                .getParent().getChild("sltConType27E").setText(connctionTypeValue).setValue(connctionTypeValue); 
                        this.getDescendantOfName("lblReconnAttemptCount_27E").setText(objEvent.reconnectAttemptCount, true)
                                .getParent().getChild("txtReconnAttemptCount_27E").setValue(objEvent.reconnectAttemptCount);
                        this.getDescendantOfName("lblDelay_27E").setText(objEvent.reconnectAttemptDelay, true)
                                .getParent().getChild("txtDelay_27E").setValue(objEvent.reconnectAttemptDelay);
                        if(objEvent.connectionType == tibco.admin.Main.getServer().getDynamicProperty("@@option_sltConTypeJNDI27E")) { //display JNDI screen
                            this.getDescendantOfName("lblJndiConfig27E").setText(objEvent.JNDISharedConfigName, true).
                                    getParent().getChild("btnSelectJNDI27E").setText(objEvent.JNDISharedConfigName, true);
                            this.getDescendantOfName("lblTopicConnFactory27E").setText(objEvent.topicConnectionFactory, true).
                                    getParent().getChild("txtTopicConnFactory27E").setValue(objEvent.topicConnectionFactory);
                            this.getDescendantOfName("lblProURL27E").setText("", true).
                                    getParent().getChild("txtProURL27E").setValue("");
                        }
                        else { //display XA screen
                            this.getDescendantOfName("lblProURL27E").setText(objEvent.providerURL, true).
                                    getParent().getChild("txtProURL27E").setValue(objEvent.providerURL);
                            this.getDescendantOfName("lblJndiConfig27E").setText("", true).
                                    getParent().getChild("btnSelectJNDI27E").setText(tibco.admin.Main.getServer().getDynamicProperty("@@select27E"), true);
                            this.getDescendantOfName("lblTopicConnFactory27E").setText("", true).
                                    getParent().getChild("txtTopicConnFactory27E").setValue(tibco.admin.Main.getServer().getDynamicProperty("@@default_topicConnFactory27E"));
                        }
                        this.setConnTypeDisplay(objEvent.connectionType);
                        this.getDescendantOfName("lblEMSUsername27E").setText(objEvent.username, true).
                                getParent().getChild("txtEMSUsername27E").setValue(objEvent.username);
                        this.getDescendantOfName("lblEMSPwd27E").setText("<i>Hidden</i>", true).
                                getParent().getChild("txtEMSPwd27E").setValue(objEvent.password);
                    }
                    else {
                        this.setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                        this.clearEMSDetails(null);
                    }

                }

                plugin.prototype.createEMSDetails = function(objEvent) {
                    this.setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    this.passedItems = {"txtName_27E":true,
                        "txtReconnAttemptCount_27E":true,
                        "txtDelay_27E":true,
                        "txtEMSUsername27E":true};
                    this.addMode = true;
                    this.clearEMSDetails(new Object());
                    this.getDescendantOfName("lblMilliseconds27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    this.editEMSDetails(this.getDescendantOfName("btnEdit_27E"));
                    this.getDescendantOfName("blkEdit27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true).repaint();
                    this.getDescendantOfName("blkCreate27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true).repaint();
                    this.getDescendantOfName("txtName_27E").setEnabled(jsx3.gui.Form.STATEENABLED, true)
                            .setValue(objEvent.name);
                    this.getDescendantOfName("sltConType27E").setValue(tibco.admin.Main.getServer().getDynamicProperty("@@default_sltConType27E"));
                    this.setConnTypeDisplay(this.getDescendantOfName("sltConType27E").getValue());
                    this.environmentID = objEvent.environmentID;
                    this.environmentName = objEvent.environmentName;
                    this.getDescendantOfName("btnSelectJNDI27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                    this.enableSaveBtn();
                }

                plugin.prototype.cancelCreateEMS = function(button) {
                    this.addMode = false;
                    this.setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    this.clearEMSDetails(new Object());
                    this.getDescendantOfName("txtName_27E").setEnabled(jsx3.gui.Form.STATEDISABLED, true);
                    this.publishAddOver();
                }

                plugin.prototype.resetEMSPane = function() {
                    this.setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    this.clearEMSDetails();
                }

                plugin.prototype.clearEMSDetails = function(objEvent) {
                    if(this.handler && this.handler.DetailsEditMode) {
                        this.cancelEditEMS(this.getDescendantOfName("btnCancel_27E"));
                        var editPane = this.getDescendantOfName("blkEdit27E");
                        if(editPane.getDisplay() == jsx3.gui.Block.DISPLAYNONE) {
                            editPane.setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true).repaint();
                            editPane.getParent().getChild("blkCreate27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true).repaint();
                        }
                    }
                    var editButton = this.getDescendantOfName("btnEdit_27E");
                    editButton.setEnabled(jsx3.gui.Form.STATEDISABLED, true);
                    var textboxes = this.getDescendantsOfType(jsx3.gui.TextBox);
                    for(var i = 0; i < textboxes.length; i++) {
                        textboxes[i].setValue("").getParent().getChild(1).setText("", true);
                        if(textboxes[i].getName() == "txtProURL27E")
                        {
                            var default_url = tibco.admin.Main.getServer().getDynamicProperty("@@default_txtProURL27E");
                            textboxes[i].setValue(default_url).getParent().getChild(1).setText("", true);
                        }
                        if(textboxes[i].getName() == "txtEMSUsername27E")
                        {
                            var default_name = tibco.admin.Main.getServer().getDynamicProperty("@@default_txtEMSUsername27E");
                            textboxes[i].setValue(default_name).getParent().getChild(1).setText("", true);
                        }
                        if(textboxes[i].getName() == "txtReconnAttemptCount_27E")
                        {
                            var default_name = tibco.admin.Main.getServer().getDynamicProperty("@@reconnectAttemptDefaultCount27E");
                            textboxes[i].setValue(default_name).getParent().getChild(1).setText("", true);
                        }
                        if(textboxes[i].getName() == "txtDelay_27E")
                        {
                            var default_name = tibco.admin.Main.getServer().getDynamicProperty("@@reconnectAttemptDelayDefault27E");
                            textboxes[i].setValue(default_name).getParent().getChild(1).setText("", true);
                        }
                        if(textboxes[i].getName() == "txtTopicConnFactory27E")
                        {
                            var default_name = tibco.admin.Main.getServer().getDynamicProperty("@@default_topicConnFactory27E");
                            textboxes[i].setValue(default_name).getParent().getChild(1).setText("", true);
                        }
                    }
                    this.getDescendantOfName("lblMilliseconds27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    this.getDescendantOfName("lblContype_27E").setText("", true)
                            .getParent().getChild("sltConType27E").setValue("");
                    this.getDescendantOfName("blkJNDI27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    this.getDescendantOfName("blkDirect27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true);
                    this.getDescendantOfName("btnSelectJNDI27E").setDisplay(jsx3.gui.Block.DISPLAYNONE, true)
                            .setText(tibco.admin.Main.getServer().getDynamicProperty("@@select27E"), true)
                            .getParent().getChild("lblJndiConfig27E").setDisplay(jsx3.gui.Block.DISPLAYBLOCK, true);
                }

                plugin.prototype.calleditServiceBusConfiguration = function() {
                    var objService = tibco.admin.Main.loadService("tibco.admin",
                            "tibco/admin/enterpriseAssets/envDef/envDtls/medBus/serDtls/rules/editMedBusRules.xml",
                            "editServiceBusConfiguration",
                            "get Service Bus Configurations");
                    //subscribe and call
                    objService.entityID = this.entityID;
                    objService.subscribe(jsx3.net.Service.ON_SUCCESS, this, this.oneditServiceBusConfigurationSuccess);
                    objService.setEndpointURL(tibco.admin.util.ServiceHelper.getEnvironmentEndpointURL())
                    objService.doCall();
                };

                plugin.prototype.oneditServiceBusConfigurationSuccess = function(objEvent) {
                    this.cancelEditEMS(this.getDescendantOfName("btnCancel_27E"));
                    this.getDescendantOfName("btnEdit_27E").setEnabled(jsx3.gui.Form.STATEENABLED, true);
                    var lbl = this.getDescendantOfName("lblDescription_27E");
                    lbl.setText(lbl.getParent().getChild("txtDescription_27E").getValue(), true);

                    lbl = this.getDescendantOfName("lblReconnAttemptCount_27E");
                    lbl.setText(lbl.getParent().getChild("txtReconnAttemptCount_27E").getValue(), true);

                    lbl = this.getDescendantOfName("lblDelay_27E");
                    lbl.setText(lbl.getParent().getChild("txtDelay_27E").getValue(), true);

                    lbl = this.getDescendantOfName("lblContype_27E");
                    var selectedText = lbl.getParent().getChild("sltConType27E").getValue();
                    lbl.setText(selectedText, true);
                    this.setConnTypeDisplay(selectedText);
                    if(selectedText == tibco.admin.Main.getServer().getDynamicProperty("@@option_sltConTypeJNDI27E")) { //display JNDI screen
                        lbl = this.getDescendantOfName("lblJndiConfig27E");
                        lbl.setText(lbl.getParent().getChild("btnSelectJNDI27E").getText(), true);

                        lbl = this.getDescendantOfName("lblTopicConnFactory27E");
                        lbl.setText(lbl.getParent().getChild("txtTopicConnFactory27E").getValue(), true);

                    }
                    else { //display XA screen
                        lbl = this.getDescendantOfName("lblProURL27E");
                        lbl.setText(lbl.getParent().getChild("txtProURL27E").getValue(), true);
                    }

                    lbl = this.getDescendantOfName("lblEMSUsername27E");
                    lbl.setText(this.getDescendantOfName("txtEMSUsername27E").getValue(), true);
                    lbl = this.getDescendantOfName("lblEMSPwd27E");
                    lbl.setText("<i>Hidden</i>", true);
                };

                plugin.prototype.calladdServiceBusConfiguration = function() {
                    var objService = tibco.admin.Main.loadService("tibco.admin",
                            "tibco/admin/enterpriseAssets/envDef/envDtls/medBus/serDtls/rules/addMedBusRules.xml",
                            "addServiceBusConfiguration",
                            "add Service Bus Configuration");
                    //subscribe and call
                    objService.subscribe(jsx3.net.Service.ON_SUCCESS, this, this.onaddServiceBusConfigurationSuccess);
                    objService.subscribe(jsx3.net.Service.ON_ERROR, this, this.onaddServiceBusConfigurationError);
                    objService.subscribe(jsx3.net.Service.ON_INVALID, this, this.onaddServiceBusConfigurationInvalid);
                    objService.setEndpointURL(tibco.admin.util.ServiceHelper.getEnvironmentEndpointURL())
                    objService.environmentName = this.environmentName;
                    objService.entityID = this.environmentID;
                    objService.doCall();
                };

                plugin.prototype.onaddServiceBusConfigurationSuccess = function(objEvent) {
                    this.cancelCreateEMS();
                };

                plugin.prototype.onaddServiceBusConfigurationError = function(objEvent) {
                    this.cancelCreateEMS();

                };

                plugin.prototype.onaddServiceBusConfigurationInvalid = function(objEvent) {
                    this.cancelCreateEMS();
                };

                plugin.prototype.publishAddOver = function() {
                    var msg = new Object();
                    msg.subject = tibco.admin.enterpriseAssets.envDef.EventID.EMS_CREATE_OVER;
                    tibco.admin.PubSub.publish(msg);
                }

                plugin.prototype.validateField = function(obj, strValue) {
                    this.passedItems[obj.getName()] = tibco.admin.util.Validation.doValidateNotEmptyNoWhSpace(obj, strValue);
                    if(obj.getName() == "txtProURL27E" && this.passedItems[obj.getName()]) {
                        var regex = new RegExp("tcp://([-a-zA-Z0-9\\.]+)(:(\\d)+)?", "ig");
                        var match = obj.getValue().match(regex);
                        if(match == null || match == "") {
                            this.passedItems["txtProURL27E"] = false;
                            obj.setBackgroundColor("yellow", true);
                            obj.setTip(tibco.admin.Main.getServer().getDynamicProperty("@@ProviderURLInvalidTip27E"));
                            this.enableSaveBtn();
                        }
                        else if(match != obj.getValue()) {
                                obj.setBackgroundColor("yellow", true);
                                obj.setTip(tibco.admin.Main.getServer().getDynamicProperty("@@ProviderURLInvalidTip27E"));
//                                var me = this;
//                                tibco.admin.Main.confirm(tibco.admin.Main.getServer().getDynamicProperty("@@ProviderURLInvalidTitle27E"),
//                                        tibco.admin.Main.getServer().getDynamicProperty("@@ProviderURLInvalidMessage27E", match),
//                                        function(dialog) {
//                                            obj.setValue(match);
//                                            obj.setBackgroundColor("#FFFFFF");
//                                            obj.setTip("");
//                                            me.passedItems["txtProURL27E"] = true;
//                                            me.enableSaveBtn();
//                                            dialog.doClose();
//                                        }, null, null, null, null,
//                                        function(dialog) {
//                                            obj.setBackgroundColor("yellow", true);
//                                            obj.setTip(tibco.admin.Main.getServer().getDynamicProperty("@@ProviderURLInvalidTip27E"));
//                                            me.passedItems["txtProURL27E"] = false;
//                                            me.enableSaveBtn();
//                                            dialog.doClose();
//                                        }, null, null);

                        }
                        else {
                            obj.setBackgroundColor("white", true);
                            obj.setTip("");
                        }
                    }
                    this.enableSaveBtn();
                }

                plugin.prototype.loadJNDIScreen = function() {
                    var parent = tibco.admin.Main.getServer().getBodyBlock();
                    tibco.admin.Main.loadUIResourceAsync(parent,
                            "tibco.admin",
                            "tibco/admin/enterpriseAssets/envDef/envDtls/medBus/serDtls/ui/selectResource.xml",
                            this,
                            this.callgetResourceConfigurationsInEnterprise);
                }

                plugin.prototype.callgetResourceConfigurationsInEnterprise = function(block) {
                    var objService = tibco.admin.Main.loadService("tibco.admin",
                            "tibco/admin/enterpriseAssets/envDef/envDtls/medBus/serDtls/rules/getJNDIResourcesForMedBus.xml",
                            "getResourceConfigurationsInEnterprise",
                            "get Resource Configs In Enterprise");
                    //subscribe and call
                    objService.entityID = this.environmentID;
                    var me = this;
                    objService.subscribe(jsx3.net.Service.ON_SUCCESS, me.ongetResourceConfigurationsInEnterpriseSuccess);
                    objService.setEndpointURL(tibco.admin.util.ServiceHelper.getSharedResourcesEndpointURL());
                    objService.doCall();
                };

                plugin.prototype.ongetResourceConfigurationsInEnterpriseSuccess = function(objEvent) {
                    var list = tibco.admin.Main.getServer().getBodyBlock().getDescendantOfName("mtxJNDIResource27E");
                    var cacheDocument = list.getXML();
                    list.setXMLTransformers(tibco.admin.Main.resolveURI("tibco.admin", "tibco/admin/enterpriseAssets/envDef/envDtls/medBus/serDtls/xml/transform.xsl"));
                    list.setXSLParam("filterParam", "JNDI");
                    list.setSourceXML(cacheDocument);
                    list.repaint();

                };

                plugin.prototype.setSelectedJNDIValue = function(list) {
                    var selectedRecord = list.getSelectedNodes().getItem(0);
                    this.getDescendantOfName("lblJndiConfig27E").setText(selectedRecord.getAttribute("name"), true).
                            getParent().getChild("btnSelectJNDI27E").setText(selectedRecord.getAttribute("name"), true);
                    this.jndiEntityID = selectedRecord.getAttribute("jsxid");
                    list.getAncestorOfType(jsx3.gui.Dialog).doClose();
                    this.passedItems["sharedJNDIResource"] = true;
                    this.enableSaveBtn();
                }

                plugin.prototype.enableSaveBtn = function() {    //btnSaveAdd_27E
                    var allPassed = true;
                    for(var item in this.passedItems) {
                        if(!this.passedItems[item]) {
                            allPassed = false;
                            break;
                        }
                    }
                    if(allPassed) {
                        this.getDescendantOfName(this.addMode?"btnSaveAdd_27E":"btnSave_27E").setEnabled(jsx3.gui.Form.STATEENABLED, true);
                    }
                    else {
                        this.getDescendantOfName(this.addMode?"btnSaveAdd_27E":"btnSave_27E").setEnabled(jsx3.gui.Form.STATEDISABLED, true);
                    }
                }

                plugin.prototype.testConnection = function(event) {
                    var objService = tibco.admin.Main.loadService("tibco.admin",
                            "tibco/admin/enterpriseAssets/shdResDefs/EMS/rules/testEmsResource.xml",
                            "testEmsResource", "Test EMS Shared Resource");
                    objService.setEndpointURL(tibco.admin.util.ServiceHelper.getSharedResourcesEndpointURL());

                    objService.name = this.getDescendantOfName("txtName_27E").getValue();
                    objService.description = this.getDescendantOfName("txtDescription_27E").getValue();
                    this.setRequestDetails(objService);

                    //subscribe and call
                    objService.subscribe(jsx3.net.Service.ON_SUCCESS, this, this.onCallTestConnectionSuccess);
                    objService.doCall();
                }

                plugin.prototype.setRequestDetails = function(objService) {
                    objService.username = this.getDescendantOfName("txtEMSUsername27E").getValue();
                    objService.password = this.getDescendantOfName("txtEMSPwd27E").getValue();
                    objService.subtype = this.getDescendantOfName("sltConType27E").getValue();

                    switch(objService.subtype) {
                        case "DIRECT":
                            objService.providerURL = this.getDescendantOfName("txtProURL27E").getValue();
                            break;
                        case "JNDI":
                            objService.JNDISharedConfigName = this.getDescendantOfName("btnSelectJNDI27E").getText();
                            objService.topicConnectionFactory = this.getDescendantOfName("txtTopicConnFactory27E").getValue();
                            break;
                    }
                }

                plugin.prototype.onCallTestConnectionSuccess = function(objEvent) {
                    var response = tibco.admin.Main.getServer().Cache.getDocument("xmlCacheIDTestConnectionResponse_25F").getRecordNode("jsxroot");

                    if(response.getAttribute("wasSuccessful") == 'true') {
                        tibco.admin.Main.alert(tibco.admin.Main.getServer().getDynamicProperty("@TestConSuccess27E"), tibco.admin.Main.getServer().getDynamicProperty("@TestConSuccessMSG27E"));
                    }
                    else {
                        tibco.admin.Main.alert(tibco.admin.Main.getServer().getDynamicProperty("@TestConFailed27E"), response.getAttribute("summary"));
                    }
                }
            }
            );
}
